package com.lxs.mall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lxs.common.validator.ListValue;
import com.lxs.common.validator.group.AddGroupInterface;
import com.lxs.common.validator.group.UpdateGroupInterface;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;


/**
 * 品牌
 * JSR303校验
 * 1，引入 spring-boot-starter-validation
 * 2, entity实体类的字段加上校验的注解如：@NotNull,@NotEmpty
 * 3,在controller 的对应方法的实体类之前加上@validation
 * 4，通过绑定BindingResult 获取校验结果信息
 * 5，通过FiledError 获取具体字段校验信息，封装Map,返回前台
 * @author lxs
 * @email 1404637866@qq.com
 * @date 2023-05-11 21:21:03
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@TableId
	@NotNull(message = "更新品牌时brandId不能为空",groups = UpdateGroupInterface.class)
	@Null(message = "添加品牌时id必须为空",groups = AddGroupInterface.class)
	private Long brandId;
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌名称不能为空",groups = {AddGroupInterface.class, UpdateGroupInterface.class})
	private String name;
	/**
	 * 品牌logo地址
	 */
	@NotBlank(message = "logo地址不能为空")
	@URL(message="品牌logo地址必须是一个合法的地址")
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@ListValue(val={0,1},groups = {AddGroupInterface.class,UpdateGroupInterface.class})
	private Integer showStatus;
	/**
	 * 检索首字母
	 */
	@NotBlank(message = "检索字母不能为空",groups = {AddGroupInterface.class, UpdateGroupInterface.class})
	@Pattern(regexp="^[a-zA-Z]$",message = "检索内容必须为a-zA-Z之间的字母",groups = {AddGroupInterface.class, UpdateGroupInterface.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(message = "排序不能为空",groups = {AddGroupInterface.class, UpdateGroupInterface.class})
	@Min(value = 0,message = "顺序不能小于0",groups = {AddGroupInterface.class, UpdateGroupInterface.class})
	private Integer sort;

}
